package com.platform.enums.formatters;

import com.platform.enums.FunctionStatus;
import org.springframework.format.Formatter;

import java.text.ParseException;
import java.util.Locale;
import java.util.Objects;

/**
 * Description: 菜单类型枚举转换-MVC
 *
 * @author libin Created on 2019/7/24
 **/
public class FunctionStatusFormatter implements Formatter<FunctionStatus> {
    @Override
    public FunctionStatus parse(String text, Locale locale) throws ParseException {
        return FunctionStatus.getByValue(Integer.parseInt(text));
    }

    @Override
    public String print(FunctionStatus object, Locale locale) {
        return Objects.toString(object.getCode());
    }
}
